package model

import (
	"github.com/pkg/errors"
	"usercenter/utils/logx"
)

func migration() error {
	// 自动迁移模式
	err := GlobalDB.Set("gorm:table_options", "charset=utf8mb4").
		AutoMigrate(
			&User{},
			&Good{},
			&Account{},
			&CashIn{},
			&CashOut{},
			&OrderBuy{},
			&OrderSale{},
			&Deal{},
			&UserSys{},
			&ProfilePhoto{},
		)
	if err != nil {
		return errors.Wrap(err, "migrate failure")
	}
	logx.LogrusObj.Infoln("[GORM] migrate success")
	return nil
}
